<template>
	<view class="participant">
		<view>
		  <banner-ad></banner-ad>
		</view>
		<view class="padding-left30 padding-bottom30 padding-top30">
			<view class="mc-g8 f14 text-center">共 23 位用户</view>
			<view class="margin-top30">
				<block  v-for="(item,index) in 100" :key="index">
					<image src="../../../../static/images/group_icon.jpg" mode="aspectFill" class="avatar" :class="{'margin-left10':(index%10!=0)}" ></image>
				</block>
			</view>
		</view>
	</view>
</template>

<script>
	import uniLoadMore from '@/components/uni-load-more/uni-load-more.vue'
	let gData = {};
	let _self;
	export default {
		components: {
			uniLoadMore
		},
		data() {
			return {
				list: [],
				total: 0,
				status: "more",
				contentText: {
					contentdown: "点击加载",
					contentrefresh: "正在加载...",
					contentnomore: ""
				}
			}
		},
		onLoad(options) {
			_self = this;
			this.initList()
		},
		onUnload() {
			gData = {}; /*因为全局变量会保存，再次打开该页面时会造成一些数据错误 */
		},
		// 下拉刷新
		onPullDownRefresh() {
			this.initList();
		},
		// 上拉加载
		onReachBottom() {
			this.loadList();
		},
		methods: {
			// 初始化列表
			initList() {
				gData.page = 0;
				this.list = [];
				this.status = "more";
				this.loadList();
			},
			// 加载列表
			async loadList() {
				if (this.status == "more") {
					const page = gData.page + 1;
					this.status = "loading";
					const pageSize = 10;
					try {
						let data = await this.$api.home.myPrize({
							page: page, // 页数
							rows: pageSize //
						});
						console.log(data)
						
						const addList = data.list || [];
						this.list = this.list.concat(addList)
						gData.page = page;
						this.total = data.total;
						const noMore = (page * pageSize) >= data.total;
						this.status = noMore ? "noMore" : "more";
					} catch (e) {
						this.status = "more";
						console.log('request fail', e);
					}
				};
			},
			// ---------------------------------------
			// 保存二维码
			setFormId(e) {
				// _self.$api.setFormId(e);
			},
		},
	}
</script>

<style lang="scss" scoped>
	.participant {
		color: #555555;
		font-size: 32rpx;
		
		.avatar{
			width: 60rpx;
			height: 60rpx;
		}
	}
</style>
